package com.lmt_10;

import com.lmt_5.Student;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class CollectionsTest {
    public static void main(String[] args) {
        List<String> name = new ArrayList<>();
        Collections.addAll(name,"张三","李四","王五"); //批量添加数据
        System.out.println(name);

        Collections.shuffle(name); // 打乱顺序
        System.out.println(name);

        List<Integer> list = new ArrayList<>();
        list.add(3);
        list.add(5);
        list.add(2);
        Collections.sort(list);
        System.out.println(list);

        List<Student>students = new ArrayList<>();
        students.add(new Student("张三",10));
        students.add(new Student("李四",50));
        students.add(new Student("王五",11));
        Collections.sort(students, (Student o1, Student o2)-> o1.getAge() - o2.getAge());
        System.out.println(students);

    }
}
